<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Insert title here</title>
  <link rel="stylesheet" href="lilei.css">
</head>

<body>
  <div id="xgmm">
    <div class="row" style="height: 50px;border-bottom: 1px solid rgb(235, 235, 235);">
      <div style="position: absolute;;width: 100px;margin-left:30px;margin-top: 15px;">修改密码</div>

    </div>
    <div class="row" style="height:200px;border-bottom: 1px solid rgb(235, 235, 235);">
      <div style="margin-top: 70px;margin-bottom: 20px;">
        <span style="margin-left: 100px;">原始密码：</span>
        <input id="oldpwd" type="text" v-model="oldpwd" style="margin-left: 30px;width:250px;height: 25px;"
          placeholder="密码：请输入原始密码">
      </div>
      <div style="margin-top: 15px;margin-bottom: 20px;">
        <span style="margin-left: 116px;">新密码：</span>
        <input id="newpwd" type="text" v-model="newpwd" style="margin-left: 30px;width:250px;height: 25px;"
          placeholder="密码：请输入新密码">
      </div>
      <div style="margin-top: 15px;margin-bottom: 20px;">
        <span style="margin-left: 83px;">确认新密码：</span>
        <input id="repwd" type="text" v-model="repwd" style="margin-left: 30px;width:250px;height: 25px;"
          placeholder="密码：请再次确认新密码">
      </div>

    </div>
    <div>
      <div style="margin-left: 400px;margin-top:15px">
        <button class="btn btn-default" v-on:click="aff(oldpwd,newpwd,repwd)"
          style="width: 70px;height: 30px;line-height: 10px;">确认</button>
        <button class="btn btn-default" style="width: 70px;height: 30px;line-height: 10px;">取消</button>
      </div>
    </div>

  </div>

  <!-- 引入VUE -->
  <script src="plugins/vue-2.6.10/vue-resource.min.js"></script>
  <script src="plugins/vue-2.6.10/vue.js"></script>
  <!-- 引入axios -->
  <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
  <script>
var account = window.sessionStorage.getItem("account");

    new Vue({
      el: "#xgmm",
      data: {
        acc: account,
        oldpwd: "",
        newpwd: "",
        repwd: ""
      },
      methods: {
        aff: function (oldpwd, newpwd, repwd) {
          axios
            .get("user/changepwd", {
              params: {
                account: this.acc,
                oldpwd: oldpwd,
                newpwd: newpwd,
                repwd: repwd
              }
            })
            .then(res => {
              console.info(res.data.message)
              if (res.data.message == ('修改密码成功')) {
                alert(res.data.message);
                window.parent.location.href='http://localhost:8080/login.html';
              } else {
                alert('系统异常')
              }
            })
        }
      }
    });
  </script>
</body>

</html>